<?php
$this->Html->addCrumb('Passcodes', '/admin/passcodes');
$this->Html->addCrumb('Edit');
$this->Html->scriptStart(array('inline' => false));
echo '
      $(function(){
        $("#PasscodeAdminEditForm").TWS_Form( {
          validate : {
          rules : {
            PasscodeId : {required : true, help : "This is the passcode that is entered by the user when they register"},
            PasscodeRoleName : {help : "This is the role or level of access that is associated with the passcode", required : true}
          }
          }});
       
         $("#deleteBtn").click(function(event){
          if(!$("#deleteBtn").attr("data-delete-confirm")) {
          $("#deleteBtn").attr("data-delete-confirm","");
            $.TWS_Overlay("confirm", {title : "Delete confirmation", message : "Are you sure you want to delete this record?", buttons : {ok :{onclick : function () { $.TWS_Overlay("hide"); $("#deleteBtn").attr("data-delete-confirm",true).trigger("click");}}}});
            event.preventDefault();
          }
        });
         });
       ';
$this->Html->scriptEnd();

?>


<h1>Edit Passcode</h1>
<?php echo $this->Session->flash();?>
<?php echo '<div id="actionLink">'.$this->Html->link('Back to list of Passcodes',array('action'=>'index', $this->layout=>true)).'</div>'; ?>

<?php echo $this->element('errors', array('errors' => isset($errors)? $errors : null)); ?>
<?php

echo $this->TWSForm->create('Passcode',  array(
    'inputDefaults' => array(
        'div' => array('class'=>'row')),
        'class'=>'inlineForm',
        'type'=>'file'));
echo '<p>Passcode: '.$this->request->data['Passcode']['id'].'</p>';
echo $this->TWSForm->input('id', array('name'=>'PasscodeId', 'type'=>'hidden', 'label'=>'<span class="required">*</span>Passcode'));
echo $this->TWSForm->input('role_name', array('name'=>'PasscodeRoleName', 'type'=>'select', 'label'=>'<span class="required">*</span>Role', 'options'=>$options));
echo $this->TWSForm->submit('Update', array('id'=>'editBtn', 'name'=>'editBtn', 'class'=>'button', 'div'=>false));
echo $this->TWSForm->submit("Delete", array('id'=>'deleteBtn','name'=>'deleteBtn', 'class'=>'button', 'div'=>false));
echo $this->TWSForm->end();

?>